#include "FileEnde.h"
#include "ui_FileEnde.h"
#include <QFileDialog>
#include "Ende.h"


FileEnde::FileEnde(QWidget *parent)
    : KzWidget(parent)
    , ui(new Ui::FileEnde)
{
    ui->setupUi(this);
    InitConnect();
}

FileEnde::~FileEnde()
{
    delete ui;
}


void FileEnde::InitConnect()
{
    connect(ui->confirmBtn,&QPushButton::clicked,this,&FileEnde::SelectFile);
    connect(ui->okBtn,&QPushButton::clicked,this,&FileEnde::EncodeFile);

}

void FileEnde::SelectFile(bool checked){
    // 选择使用的文件
    QFileDialog* fileDialog = new QFileDialog(this);
    fileDialog->setWindowTitle(QStringLiteral("选择文件"));
    fileDialog->setDirectory("./");
    fileDialog->setViewMode(QFileDialog::Detail);
    if (fileDialog->exec()) {
        fileNameList = fileDialog->selectedFiles();
        ui->fileEdit->setText(fileNameList[0]);
    }
    
}

void FileEnde::EncodeFile(bool checked) {
    QString fileName = ui->fileEdit->text();
    Ende::FileEncode(fileName,"");
}
